package com.qingyunge.app.func;
import com.qingyunge.util.KeywordUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class SplitConfFuncton extends TableFunction<Row> {
    public void eval(String str){
        try {
            String[] s = str.split("\\s+");
            List<String> list = new ArrayList<>(Arrays.asList(s));
            for (String word:list) {
                collect(Row.of(word));
            }
        } catch (Exception e) {
            collect(Row.of(str));
        }
    }
}
